<?php
// +----------------------------------------------------------------------
// | 海豚PHP框架 [ DolphinPHP ]
// +----------------------------------------------------------------------
// | 版权所有 2016~2017 河源市卓锐科技有限公司 [ http://www.zrthink.com ]
// +----------------------------------------------------------------------
// | 官方网站: http://dolphinphp.com
// +----------------------------------------------------------------------
// | 开源协议 ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------

	namespace app\cms\api;

	use app\cms\model\Slider as SliderMode;
	use app\common\controller\API;

	/**
	 * 滚动图片控制器
	 * @package app\cms\admin
	 */
	class Slider extends API
	{
		/**
		 * 滚动图片列表
		 * api POST /cms/Slider/index
		 * @param $type_id int 轮播类型ID
		 * @return $data array 数据
		 * @return mixed
		 * @throws \think\Exception
		 * @throws \think\exception\DbException
		 */
		public function index()
		{
			$type_id = $this->request->param('type_id');
			$list_type = SliderMode::where(['status' => 1, 'typeid' => $type_id])->order('sort asc')->select();
			foreach ($list_type as &$item)
			{
				$item['cover'] = get_file_path($item['cover']);
			}
			unset($item);
			$this->result($list_type);
		}
	}